/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import junit.framework.TestCase;





/**
 * Performs Validation Test for url validations.
 *
 * @version $Revision: 1128446 $ $Date: 2011-05-27 13:29:27 -0700 (Fri, 27 May 2011) $
 */
public class UrlValidatorTest extends TestCase {

   private boolean printStatus = false;
   private boolean printIndex = false;//print index that indicates current scheme,host,port,path, query test were using.

   public UrlValidatorTest(String testName) {
      super(testName);
   }

   
   
   public void testManualTest()
   {
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   System.out.println(urlVal.isValid("http://www.google.com") + " true 1");
	   System.out.println(urlVal.isValid("3ht://www.google.com") + " false 2");
	   System.out.println(urlVal.isValid("h3t://www.google.com") + " true 3");
	   System.out.println(urlVal.isValid("http:/www.google.com") + " false 4");
	   System.out.println(urlVal.isValid("http/www.google.com") + " false 5");
	   System.out.println(urlVal.isValid("://ww.google.com") + " false 6");
	   System.out.println(urlVal.isValid("http://www.google.com:80") + " true 7");
	   System.out.println(urlVal.isValid("http://0.0.0.0") + " true 8");
	   System.out.println(urlVal.isValid("http://1.2.3.4.5") + " false 9");
	   System.out.println(urlVal.isValid("http://255.255.255.255") + " true 10");
	   System.out.println(urlVal.isValid("http://255.255.255.256") + " false 11");
	   System.out.println(urlVal.isValid(".1.2.3.4") + " false 12");
	   System.out.println(urlVal.isValid("http://go.cc") + " true 13");
	   System.out.println(urlVal.isValid("http://go.1aa") + " false 14");
	   System.out.println(urlVal.isValid("http://www.google.com:80") + " true 15");
	   System.out.println(urlVal.isValid("http://www.google.com:-1") + " false 16");
	   System.out.println(urlVal.isValid("http://www.google.com/test1") + " true 17");
	   System.out.println(urlVal.isValid("http://www.google.com/$23") + " true 18");
	   System.out.println(urlVal.isValid("http://www.google.com/..//file") + " false 19");
	   System.out.println(urlVal.isValid("http://www.google.com?action=view") + " true 20");
	   System.out.println(urlVal.isValid("http://www.google.com?action=edit&mode=up") + " true 21");	   
   }
   
   //Partition Tests
   //I have two partition testing cases set up in the following two test cases
   //Please read the comment on the partition test for clarifications
   
   //Partition: IP Addresses
   //Description:   This test implements the first chosen partitioning for the isValid method
   //				I will test several IP Address valid and invalid to see how the method
   //				handles them.
   public void testYourFirstPartition()
   {
	   //Initialization
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   boolean shouldBeTrue = true;
	   boolean shouldBeFalse = false;

	   System.out.println("Start Input Partition Test Part 1 - IP Addresses");
	   
	   //Valid IP Addresses
	   System.out.print("Google's IP Address returned ");
	   assertTrue(urlVal.isValid("http://173.194.33.7") == shouldBeTrue);
	   System.out.println("as valid. - Passed");
	   
	   System.out.print("Pandora's IP Address returned ");
	   assertTrue(urlVal.isValid("http://208.85.40.50") == shouldBeTrue);
	   System.out.println("as valid. - Passed");
	   
	   System.out.print("Oregon State's IP Address returned ");
	   assertTrue(urlVal.isValid("http://128.193.4.112") == shouldBeTrue);
	   System.out.println("as valid. - Passed");	   
	   
	   //Invalid IP Addresses
	   System.out.print("Invalid IP address 1.2.3.4.5 returned ");
	   assertTrue(urlVal.isValid("http://1.2.3.4.5") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid IP address -1.-2.-3.-4.-5 returned ");
	   assertTrue(urlVal.isValid("http://-1.-2.-3.-4.-5") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	     
	   System.out.print("Invalid IP address 1.2.3 returned ");
	   assertTrue(urlVal.isValid("http://1.2.3") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid Google IP address http://.173.194.33.7 returned ");
	   assertTrue(urlVal.isValid("http://.173.194.33.7") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid Google IP address http://173.194.33.7. returned ");
	   assertTrue(urlVal.isValid("http://173.194.33.7.") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid Google IP address 173.194.33.7. returned ");
	   assertTrue(urlVal.isValid("173.194.33.7.") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid IP address 256.256.256.256 returned ");
	   assertTrue(urlVal.isValid("http://256.256.256.256") == shouldBeFalse);			//BUG
	   System.out.println("as invalid. - Passed");      
   }
   
   //Partition: Regular URL Expressions
   //Description: This test implements the second chosen partitioning for the isValid method
   //  			  I will test several URL regular expressions both valid and invalid to see how
   //			  the method handles them.
   public void testYourSecondPartition(){
	   
	   //Initialization
	   UrlValidator urlVal = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
	   boolean shouldBeTrue = true;
	   boolean shouldBeFalse = false;

	   System.out.println("Start Input Partition Test Part 2 - URLs");
	   
	   //Valid URLs
	   System.out.print("Google URL returned ");
	   assertTrue(urlVal.isValid("http://Google.com") == shouldBeTrue);
	   System.out.println("as valid. - Passed");
	   
	   System.out.print("Oregon State's URL returned ");
	   assertTrue(urlVal.isValid("http://OregonState.edu") == shouldBeTrue);
	   System.out.println("as valid. - Passed");
	      
	   //Invalid URLs
	   System.out.print("Empty URL returned ");
	   assertTrue(urlVal.isValid("http://") == shouldBeFalse);
	   System.out.println("as invalid. - Passed");
	   
	   System.out.print("Invalid httppp:/Google.com URL returned ");
	   assertTrue(urlVal.isValid("httppp:/Google.edu") == shouldBeFalse);		
	   System.out.println("as invalid. - Passed");
	      
	   System.out.print("Invalid http://Google.edu URL returned ");
	   assertTrue(urlVal.isValid("http://Google.edu") == shouldBeFalse);		//BUG
	   System.out.println("as invalid. - Passed");
	   
	   
   }
   
   public void testIsValid()
   {
	   for(int i = 0;i<10000;i++)
	   {
		   
	   }
   }
   
   public void testAnyOtherUnitTest()
   {
	   
   }
   /**
    * Create set of tests by taking the testUrlXXX arrays and
    * running through all possible permutations of their combinations.
    *
    * @param testObjects Used to create a url.
    */
   

}